<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    
</body>
<script>

    const origin = {
        name:"admin",
        age:18,
        sex:"男"
    }

    const target = {};

    for(let i in origin){
        Object.defineProperty(target, i, {
            get(){
                console.log(i, "被访问了")
                return origin[i];
            },
            set(val){
                console.log(i, "被修改成了", val)
                origin[i] = val;
            }
        })
    }

    origin.msg = "hello";

    console.log(target);

    // 无法劫持将来添加的属性
    
</script>
</html>